import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:overload_guard/app_theme.dart';

class DataDetailDetailPage extends StatefulWidget {
  final dynamic detailData;

  const DataDetailDetailPage({super.key, required this.detailData});

  @override
  State<DataDetailDetailPage> createState() => _DataDetailDetailPageState();
}

class _DataDetailDetailPageState extends State<DataDetailDetailPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("车板详细信息", style: TextStyle(color: Colors.white)),
        backgroundColor: AppTheme.primaryColor,
        centerTitle: true,
        leading: IconButton(
          icon: Icon(
            Icons.arrow_back,
            color: Colors.white,
          ),
          onPressed: () {
            Get.back();
          },
        ),
      ),
      body: ListView(
        children: [
          groupTitle("车头信息",context),
          infoTile("车牌号", widget.detailData["carNum"]),
          infoTile("型号", widget.detailData["carModel"]),
          infoTile("生产商", widget.detailData["carProducer"]),
          infoTile("所属公司", widget.detailData["carCompany"]),

          Padding(padding: EdgeInsets.only(top: 10)),

          groupTitle("车板信息",context),
          infoTile("车板号", widget.detailData["templateNum"]),
          infoTile("生产商", widget.detailData["templateProducer"]),
          infoTile("所属公司", widget.detailData["templateCompany"]),

          Padding(padding: EdgeInsets.only(top: 10)),

          groupTitle("集装箱信息",context),
          infoTile("集装箱号", widget.detailData["containerNum"]),
          infoTile("型号", widget.detailData["containerModel"]),
          infoTile("尺寸", widget.detailData["containerSize"]),
          infoTile("生产商", widget.detailData["containerProducer"]),
        ],
      ),
    );
  }

  Widget groupTitle(String title, BuildContext context){
    return Text(title, style:  Theme.of(context).textTheme.titleLarge);
  }

  Widget infoTile(title, String? message) {
    return Container(
      height: 46,
      child: ListTile(
        title: Text(title),
        trailing:Text(message ?? "暂无", style: Theme.of(context).textTheme.labelLarge),
      ),
    );
  }
}
